package com.imut.oa.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.imut.oa.annotation.AutoFill;
import com.imut.oa.contant.OperationType;
import com.imut.oa.pojo.dto.DepartmentPageQueryDTO;
import com.imut.oa.pojo.entity.Departments;
import com.imut.oa.pojo.vo.DepartmentVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Map;

@Mapper
public interface DepartmentMapper extends BaseMapper<Departments> {

    /**
     * 插入部门信息
     * @param build
     */
    @AutoFill(OperationType.INSERT)
    @Insert("insert into departments(departmentName,departmentDescription,createTime,updateTime,createUser,updateUser,isDelete) values (#{departmentName},#{departmentDescription},#{createTime},#{updateTime},#{createUser},#{updateUser},#{isDelete})")
    void customInsert(Departments build);

    /**
     * 更新部门信息
     * @param build
     */
    @AutoFill(OperationType.UPDATE)
    void updateByDepartmentId(Departments build);

    /**
     * 查询部门信息
     * @param build
     * @return
     */
    Departments getByDepartment(Departments build);

    Page<DepartmentVO> selectDepartmentPage(Page<DepartmentVO> page, @Param("dto")DepartmentPageQueryDTO dto);

    List<Map<String, Object>> getDepartmentStats();
}
